<?php
session_start();

$id = $_GET['id'];

$cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : [];

// 查找要删除的元素下标
$index = -1;
for ($i = 0;$i < count($cart);$i++){
	if ($cart[$i]['id'] == $id) {
		$index = $i;
		break;
	}
}
  if ($index > -1) {
  	array_splice($cart, $index,1);
  	$_SESSION['cart'] = $cart;
  }
 header('Location:../cart.php');